<template>
  <van-tabbar v-model="active" :placeholder="true">
    <van-tabbar-item
      v-for="(item, index) in icon"
      :key="index"
      :name="item.name"
      :to="item.name"
    >
      <span>{{ item.title }}</span>
      <template #icon="props">
        <img :src="props.active ? item.active : item.inactive" />
      </template>
    </van-tabbar-item>
  </van-tabbar>
</template>

<script>
import { ref } from "vue";
export default {
  setup() {
    const active = ref(location.hash.slice(1));
    const icon = [
      {
        name: "/home/index",
        title: "首页",
        active: "http://121.40.124.132:3000/images/index/index2.png",
        inactive: "http://121.40.124.132:3000/images/index/index.png",
      },
      {
        name: "/home/chat",
        title: "聊",
        active: "http://121.40.124.132:3000/images/index/chat2.png",
        inactive: "http://121.40.124.132:3000/images/index/chat.png",
      },
      {
        name: "/home/cus",
        title: "定制",
        active: "http://121.40.124.132:3000/images/index/dingzhi2.png",
        inactive: "http://121.40.124.132:3000/images/index/dingzhi.png",
      },
      {
        name: "/home/mine",
        title: "我的",
        active: "http://121.40.124.132:3000/images/index/mine2.png",
        inactive: "http://121.40.124.132:3000/images/index/mine.png",
      },
    ];
    return {
      icon,
      active,
    };
  },
};
</script>

<style lang="less" scoped></style>
